<template>
	<view>
		<view class="page">
		<view class="top" :style="`padding-top:`+$store.state.StatusBar.statusBar + `px`">
			<view class="top-icon"   @click="back">
				<u-icon name="arrow-left" size="42rpx" color='#fff'></u-icon>
			</view>
			<view class="top-title c-fff" >{{title}}</view>
		</view>
		<view class="body" :style="`margin-top:`+$store.state.StatusBar.statusBar + `px`">
			
			<view class="detail c-fff" v-if="detail">
				<view v-html="content"></view>
			</view>
			<view v-else>
				<view class="flex_r fa_c item" v-for="(item,index) in list">
					<view class="time c-fff">{{item.createtime}}</view>
					<view class="item-box">
						<view class="item-img">
							<image class="img" mode="aspectFill" :src="item.image"></image>
						</view>
						<view class="title c-fff">{{item.title}}</view>
						<view class="bottom flex flex-between" @click="openDetail(item)">
							<view class="c-fff">查看详情</view>
							<u-icon name="arrow-right" color="#fff" size="28rpx"></u-icon>
						</view>
					</view>
				</view>
			</view>
		</view>
		</view>
	</view>
</template>

<script>
	import {to} from '@/utils/index.js';
	export default {
		data() {
			return {
				title: '平台活动',
				pageno:1,
				type: 1,
				detail: false,
				content: '',
				list: []
			}
		},
		onReachBottom() {
			this.getList()
		},
		onLoad(option) {
			this.type = option.type
		},
		onShow(option){
			this.pageno = 1;
			this.list = [];
			this.getList();
			if(this.type == 1){
				this.title = '系统消息'
			}else{
				this.title = '平台通知'
			}
		},
		methods: {
			to,
			back(){
				if(this.detail){
					this.detail = false;
					this.content = "";
				}else{
					to()
				}
			},
			openDetail(item){
				this.detail = true;
				this.content = item.message;
			},
			async getList(){
				let url = "";
				if(this.type == 1){
					url = '/appsystem/xiaoxi?pageno='+this.pageno;
				}
				if(this.type == 2){
					let sex = this.type ? 2 : 1;
					url = '/app/pingtai/pingtaiList?pageno='+this.pageno;
				}
				let res = await this.$c.post(url)
				if(res.code == 1002){
					uni.navigateTo({
					  url: '/im/login/login'
					});
				}
				this.list = this.list.concat(res.data)
				this.pageno++;
				this.refresherTriggered = false
			},
			refresherrefresh(index) {
				console.log("下拉")
				const tabItem = this.navList[index]
				if (tabItem._refresherTriggered) {
					return;
				}
				tabItem._refresherTriggered = true
				tabItem.startSize = 1
				setTimeout(() => {
					tabItem._refresherTriggered = false
				}, 1000)
			}
		}
	}
</script>

<style scoped lang="scss">
	.page {
		width: 100vw;
		height: 100vh;
		/* background: linear-gradient(#e3ecfb, #fdedf0, #fff, #fff); */
	}
	.top {
		position: fixed;
		top: 0rpx;
		width: 100%;
		/* background-color: #e3ecfb; */
		z-index: 999;
		text-align: center;
		vertical-align: middle;
		padding:10rpx;
	}
	.top-icon {
		position: absolute;
		left: 30rpx;
		z-index: 99;
		width: 30rpx;
		height: 30rpx;
	}
	.top-title {
		line-height: 50rpx;
		display: block;
		height:50rpx;
		z-index: 99;
	}

	.body{
		padding-top:100rpx;
	}
	.nav {
		box-sizing: border-box;
		padding: 0 30rpx;
		width: 100%;
		height: 100rpx;

		.nav-icon {
			width: 40rpx;
			height: 40rpx;
		}

		.nav-list {
			height: 100%;

			.nav-list-item {
				width: 150rpx;
				height: 100%;

				.nav-list-item-title {
					margin-bottom: 10rpx;
					transition: all .3s;
				}

				.nav-str {
					opacity: 0;
					width: 50rpx;
					height: 14rpx;
					border-radius: 7rpx;
					transition: all .3s;
				}
			}

			.nav_list_item {
				font-size: 34rpx;

				.nav-list-item-title {
					transition: all .3s;
					color: #e6166a;
				}

				.nav-str {
					opacity: 1;
					background-color: #e6166a;
				}
			}

		}
	}

	.page-current {
		position: relative;
		width: 100%;
		height: 0;

		.scroll-v {
			position: relative;
			box-sizing: border-box;
			width: 100%;
			height: 0;
		}
	}



	.detail{
		padding:20rpx;
	}
	.item {
		width: 100vw ;
		height: 430rpx;
		.time{
			position: absolute;
			left: 50%;
			margin-bottom: 400rpx;
			transform: translateX(-50%);
			font-size:22rpx;
			color: #949494;
		}
		.item-box{
			margin-left:10rpx;
			margin-right:10rpx;		
			width: 100vw ;
			border-radius: 20rpx;
			background-color: rgba(255, 255, 255, 0.1);
			padding:20rpx;
		}
		.item-img {
			width: calc(100%-40rpx);
			margin-top:20rpx;
			height: 180rpx;
			background-color: #f1f1f1;
		}
		.title{
			margin-top:20rpx;
			font-size: 28rpx;
		}
		.bottom{
			margin-top:20rpx;
			font-size: 24rpx;
			padding-top:20rpx;
			border-top:1px solid #bdbdbd;
		}

		.item-infr {
			.item-infr-top {}

			.item-infr-top-img {
				width: 40rpx;
				height: 40rpx;
				overflow: hidden;
				border-radius: 50%;
				margin-left: 20rpx;
			}
		}

		.item-button {
			box-sizing: border-box;
			padding: 0 20rpx;
			height: 50rpx;
			text-align: center;
			line-height: 50rpx;
			border-radius: 25rpx;
			background-color: #e8e1e8;
		}
		.item-button_{
			box-sizing: border-box;
			padding: 0 20rpx;
			height: 50rpx;
			text-align: center;
			line-height: 50rpx;
			border-radius: 25rpx;
			background-image: linear-gradient(to right,rgba(230, 22, 106, 0.3),#e6166a);
			.item-button_icon{
				width: 30rpx;
				height: 30rpx;
				margin-right: 6rpx;
			}
		}
		
	}
</style>